<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>用户管理</title>
    <link rel="icon" href="img/q11.png" type="image/x-icon" />
    <link rel="shortcut icon" href="img/q11.png" type="image/x-icon" />
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/layui.css"  media="all">
    <style>
        tr{
            border:1px solid black;
            width: 30rem;
        }
        th{
            border:1px solid black;
            width: 30rem;
        }
        td{
            border:1px solid black;
            width: 30rem;
        }
    </style>
</head>

<body style="background-image: url(img/4.jpg);;background-size: cover;">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo layui-hide-xs layui-bg-black">调查问卷</div>
            <!-- 头部区域（可配合layui 已有的水平导航） -->
            <ul class="layui-nav layui-layout-left">
                <!-- 移动端显示 -->
                <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                    <i class="layui-icon layui-icon-spread-left"></i>
                </li>

                <li class="layui-nav-item layui-hide-xs"><a href="">问卷列表</a></li>
                <li class="layui-nav-item layui-hide-xs"><a href=""></a></li>
                <li class="layui-nav-item layui-hide-xs"><a href=""></a></li>
            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                    <a href="javascript:;">
                        <img src="img/1.jpg" class="layui-nav-img">
                        {{username}}
                    </a>
                <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                    <a href="/">
                        回到问卷首页
                    </a>
                </li>
                <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                    <a href="" onclick="logout()">
                        退出
                    </a>
                </li>
                </li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item layui-nav-itemed">

                    </li>
                    <li class="layui-nav-item">
      
                    </li>
                    <!-- <li class="layui-nav-item"><a href="javascript:;">click menu item</a></li> -->

                    <li class="layui-nav-item"><a href="" data-toggle="modal" data-target="#updatepassword">+修改密码</a></li>



                </ul>
            </div>
        </div>

        <div class="layui-body">
           
            {% for msg in msgs %}
            <table style="border:1px solid black;" >
                <thead>
                    <tr>
                        <th>问卷标题：{{msg.title}}</th>
                        <th>问卷说明：{{msg.description}}</th>
                    </tr>
                    
                    <tr>
                      
                        <th>问卷问题：{{msg.question.question}}</th>
                     
                      
                    </tr>
                </thead>


                <tbody>
                 
                    <!-- <tr>
                        <td>贤心1</td>
                        <td>2016-11-28</td>
                        <td>人生就像是一场修行 A</td>
                    </tr>
                    <tr>
                        <td>贤心2</td>
                        <td>2016-11-29</td>
                        <td>人生就像是一场修行 B</td>
                    </tr>
                    <tr>
                        <td>贤心3</td>
                        <td>2016-11-30</td>
                        <td>人生就像是一场修行 C</td>
                    </tr> -->
                </tbody>
                
            </table>
            <br>
            <br>
            {% endfor %}
        </div>

        <!-- <div class="layui-footer"> -->
        <!-- 底部固定区域 -->
        <!-- 底部固定区域 -->
        <!-- </div> -->
    </div>


    <div class="modal fade" id="updatepassword" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">修改密码</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group">
                            <input type="password" class="form-control" aria-describedby="passwordHelpInline" id="password"
                                placeholder="请输入新密码">
                            <br>
                            <input type="password" class="form-control" aria-describedby="passwordHelpInline"
                                placeholder="再输入新密码" id="confirmpassword">

                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="addsave()"
                        data-toggle="modal" data-target="#addquestionnaire">保存</button>
                </div>
            </div>
        </div>
    </div>



    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="js/layui.js" charset="utf-8"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>


    <script>





        //修改密码
        function addsave() {
            let password = $('#password').val();
            let confirmpassword = $('#confirmpassword').val();
            if (password.length > 0 && confirmpassword.length > 0 && password===confirmpassword) {
                axios({
                    method: 'post',
                    url: '/passwordDon',
                    data: {
                        password: $('#password').val(),
                        confirmpassword: $('#confirmpassword').val(),

                    }
                }).then(function (response) {
                    // axios工具下，服务器真正返回的数据在返回对象的data中
                    let res = response.data;
                    if (res.code === 200) {
                       alert("密码修改成功")
                    } else {
                        alert(res.msg);
                    }
                }).catch((err) => {

                });
            }
            else {
                alert('警告:请确认二次密码一致或不能为空');
            }

        }

        // 注销登录
        function logout() {
            axios({
                method: 'post',
                url: '/logout'
            }).then(function (response) {
                // axios工具下，服务器真正返回的数据在返回对象的data中
                let res = response.data;
                if (res.code === 200) {
                    window.location.href = '/login';
                }
            }).catch((err) => {

            });
        }


    </script>
</body>

</html>